<template>
  <div class="app-container">
    <!-- 查询 -->
    <tl-list-search ref="search" :query-param="queryParam" @search="doQuery" :isDisplayDefaultSearch="false" v-if="isHeaderDisplay">
      <template slot="search">
        <el-form-item label="接收人">
          <tl-ref-user v-model="queryParam.receivercode" :initDisplayData.sync="queryParam.receivername" @confirm="userConfirm" :externalQueryParam="{ qry_whereSql: ' enabled = 1 and  extendfield1 is not null ' }" dataType="code" :singleSelect="true"></tl-ref-user>
        </el-form-item>
        <el-form-item label="创建时间">
          <el-date-picker v-model="createonList" type="daterange" align="right" unlink-panels range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期" :picker-options="pickerOptions" value-format="yyyy-MM-dd"></el-date-picker>
        </el-form-item>
        <el-form-item label="阅读时间">
          <el-date-picker v-model="readdateList" type="daterange" align="right" unlink-panels range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期" :picker-options="pickerOptions" value-format="yyyy-MM-dd"></el-date-picker>
        </el-form-item>
        <el-form-item label="消息内容" prop="qry_content" @keyup.enter.native="doQuery">
          <el-input v-model="queryParam.qry_content" placeholder="请输入消息内容" clearable></el-input>
        </el-form-item>
        <el-form-item label="状态">
          <el-select v-model="queryParam.qry_state" clearable placeholder="请选择消息状态" @keyup.enter.native="doQuery">
            <el-option v-for="item in codeModel.stateList" :key="item.code" :label="item.name" :value="item.code"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="消息类型">
          <el-select v-model="queryParam.qry_messagetype" clearable placeholder="请选择消息类型" @keyup.enter.native="doQuery">
            <el-option v-for="item in codeModel.messagetypeList" :key="item.code" :label="item.name" :value="item.code"></el-option>
          </el-select>
        </el-form-item>
      </template>
    </tl-list-search>
    <!-- 工具栏 -->
    <tl-list-toolbar ref="toolbar" @add="openAddDialog('editForm')" @exportExcel="doExportExcel" @deleteBatch="doDeleteBatch" @refresh="doRefresh" @columnCustomize="doColumnCustomize" @displaySearch="doDisplaySearch" :disableDeleteBatch="selectedRowKeys.length <= 0" :is-display-add="false" :is-display-delete-batch="false">
      <template slot="left-btn"> </template>
    </tl-list-toolbar>
    <div>
      <!-- 列表选择 -->
      <div class="table-alert-div" ref="selector">
        <el-alert type="success" :closable="false" class="tl-table-alert-info" effect="light">
          <template slot="title">
            已选择&nbsp;<a class="tl-table-alert-info-a1">{{ selectedRowKeys.length }}</a
            >项&nbsp;&nbsp;
            <a class="tl-table-alert-info-a2" @click="doClearSelected">全部清空</a>
          </template>
        </el-alert>
      </div>
      <!--表格渲染-->
      <el-table class="tl-table" ref="mainTable" :height="tableHeight" resizable-key="tableHeight" :resizable-refs="tableResizeRefs" v-loading="loading" :data="datas" @selection-change="doSelectChange" @sort-change="doSortChange" @row-dblclick="doRowDbClick" @row-click="doRowClick" row-key="id" border fit :row-class-name="doChangeRowClassName">
        <el-table-column type="index" label="序号" width="55px" align="center"></el-table-column>
        <el-table-column prop="sendercode" label="发送人工号" width="150px" sortable="custom" sort-by="sendercode" align="center" header-align="center" :show-overflow-tooltip="true"></el-table-column>
        <el-table-column prop="sendername" label="发送人姓名" width="150px" sortable="custom" sort-by="sendername" align="center" header-align="center" :show-overflow-tooltip="true"></el-table-column>
        <el-table-column prop="receivercode" label="接收人工号" width="150px" sortable="custom" sort-by="receivercode" align="center" header-align="center" :show-overflow-tooltip="true"></el-table-column>
        <el-table-column prop="receivername" label="接收人姓名" width="150px" sortable="custom" sort-by="receivername" align="center" header-align="center" :show-overflow-tooltip="true"></el-table-column>
        <el-table-column prop="sourceid" label="来源ID" width="150px" sortable="custom" sort-by="sourceid" align="center" header-align="center" :show-overflow-tooltip="true"></el-table-column>
        <el-table-column prop="sourcetype" label="来源类型" width="150px" sortable="custom" sort-by="sourcetype" align="center" header-align="center" :show-overflow-tooltip="true"></el-table-column>
				<el-table-column prop="subject" label="主题" width="150px" sortable="custom" sort-by="subject" align="center" header-align="center" :show-overflow-tooltip="true"></el-table-column>
				<el-table-column prop="content" label="消息内容" width="300px" sortable="custom" sort-by="content" align="center" header-align="center" :show-overflow-tooltip="true"></el-table-column>
				<el-table-column prop="dispstate" label="状态" width="100px" sortable="custom" sort-by="state" align="center" header-align="center" :show-overflow-tooltip="true"></el-table-column>
				<el-table-column prop="ishtm" label="是否htm" width="150px" sortable="custom" sort-by="ishtm" align="center" header-align="center" :show-overflow-tooltip="true">
          <template slot-scope="scope">
            <span v-if="scope.row.createtype !== null">{{ scope.row.ishtml === '1' ? '是' : '否' }}</span>>
          </template>
        </el-table-column>
        <el-table-column prop="paramvalue" label="消息参数" width="150px" sortable="custom" sort-by="paramvalue" align="center" header-align="center" :show-overflow-tooltip="true"></el-table-column>
        <el-table-column prop="dispappjump" label="是否需要跳转" width="100px" sortable="custom" sort-by="appjump" align="center" header-align="center" :show-overflow-tooltip="true"></el-table-column>
        <el-table-column prop="dispmessagetype" label="消息类型" width="100px" sortable="custom" sort-by="messagetype" align="center" header-align="center" :show-overflow-tooltip="true"></el-table-column>
        <el-table-column prop="messageparam" label="扩展参数" width="150px" sortable="custom" sort-by="messageparam" align="center" header-align="center" :show-overflow-tooltip="true"></el-table-column>
        <el-table-column prop="readdate" label="阅读时间" width="170px" sortable="custom" sort-by="readdate" align="center" header-align="center" :formatter="dateTimeFormat" :show-overflow-tooltip="true"></el-table-column>
        <el-table-column prop="createon" label="创建时间" width="170px" sortable="custom" sort-by="createon" align="center" header-align="center" :formatter="dateTimeFormat" :show-overflow-tooltip="true"></el-table-column>
        <el-table-column prop="description" label="备注" min-width="250px" align="left" header-align="center" :show-overflow-tooltip="true"></el-table-column>
        <el-table-column prop="enabled" label="有效" width="100px" sortable="custom" sort-by="enabled" align="center" header-align="center">
          <template slot-scope="scope">
						<el-tag v-if="scope.row.enabled === 1" type="success">是</el-tag>
						<el-tag v-else type="danger">否</el-tag>
					</template>
				</el-table-column>
        <el-table-column label="操作" width="220px" v-slot="scope" fixed="right">
          <el-button type="text" icon="el-icon-edit" @click="openEditDialog('editForm', scope.row.id)">编辑</el-button>
          <el-dropdown trigger="hover">
            <el-button type="text" icon="el-icon-s-operation" style="margin-left:10px">更多<i class="el-icon-arrow-down el-icon--right"></i></el-button>
            <el-dropdown-menu>
              <el-dropdown-item icon="el-icon-view" @click.native="openViewDialog('editForm', scope.row.id)">查看</el-dropdown-item>
            </el-dropdown-menu>
          </el-dropdown>
        </el-table-column>
      </el-table>
      <!-- 列表分页 -->
      <el-row class="pagebar" ref="pager">
        <el-pagination @size-change="doChangeSize" @current-change="doChangeIndex" :current-page="pageInfo.currentPage" :page-sizes="pageInfo.pageSizes" :total="pageInfo.totalCount" layout="total, sizes, prev, pager, next, jumper" background class="tl-table-pagination"> </el-pagination>
      </el-row>
      <tl-edit ref="editForm" @refresh="doRefresh"></tl-edit>
    </div>
  </div>
</template>

<script>
/** mixins */
import { mixin_list } from '@tapui/mixins/mixin_list'
/** 子组件 */
import tlEdit from './edit'
/** 工具类 */
import { getAction, putAction, postAction, deleteAction } from '@tapui/utils/http'
export default {
  name: 'appMessageSys',
  mixins: [mixin_list],
  components: { tlEdit },
  data() {
    return {
      description: 'APP系统消息-列表查询',
      urlPrefix: '/appv2/appMessageSys/',
      url: {
        queryCodeList: '/appv2/appMessageSys/dataCodeList'
      },
      // 排序参数
      sorterInfo: {
        sidx: 'sortcode',
        sord: 'asc'
      },
      pickerOptions: {
        shortcuts: [{
          text: '最近一周',
          onClick(picker) {
            const end = new Date()
            const start = new Date()
            start.setTime(start.getTime() - 3600 * 1000 * 24 * 7)
            picker.$emit('pick', [start, end])
          }
        }, {
          text: '最近一个月',
          onClick(picker) {
            const end = new Date()
            const start = new Date()
            start.setTime(start.getTime() - 3600 * 1000 * 24 * 30)
            picker.$emit('pick', [start, end])
          }
        }, {
          text: '最近三个月',
          onClick(picker) {
            const end = new Date()
            const start = new Date()
            start.setTime(start.getTime() - 3600 * 1000 * 24 * 90)
            picker.$emit('pick', [start, end])
          }
        }]
      },
      createonList: [],
      readdateList: []
    }
  },
  methods: {
    beforeLoadData() {
      if (this.createonList == null) {
        this.queryParam.qry_createon1 = ''
        this.queryParam.qry_createon2 = ''
      }
      if (this.createonList != null) {
        if (this.createonList.length > 0) {
          this.queryParam.qry_createon1 = this.createonList[0]
          this.queryParam.qry_createon2 = this.createonList[1]
        }
      }
      if (this.readdateList == null) {
        this.queryParam.qry_readdate1 = ''
        this.queryParam.qry_readdate2 = ''
      }
      if (this.readdateList != null) {
        if (this.readdateList.length > 0) {
          this.queryParam.qry_readdate1 = this.readdateList[0]
          this.queryParam.qry_readdate2 = this.readdateList[1]
        }
      }
      return true
    }
  }
}
</script>

<style scoped></style>

